

	import java.io.IOException;
	import java.io.UnsupportedEncodingException;
	import java.util.ArrayList;
	import java.util.List;

	import org.apache.http.HttpEntity;
	import org.apache.http.HttpResponse;
	import org.apache.http.NameValuePair;
	import org.apache.http.client.ClientProtocolException;
	import org.apache.http.client.HttpClient;
	import org.apache.http.client.entity.UrlEncodedFormEntity;
	import org.apache.http.client.methods.HttpPost;
	import org.apache.http.impl.client.DefaultHttpClient;
	import org.apache.http.message.BasicNameValuePair;
	import org.apache.http.protocol.HTTP;
	import org.apache.http.util.EntityUtils;

	public class login  {

	        public static void main(String[] args) {

	                HttpClient client = new DefaultHttpClient();
	                String postURL = "https://www.google.com/accounts/ClientLogin";
	                HttpPost post = new HttpPost(postURL);
	                System.out.println("post is "+post.toString());
	          List<NameValuePair> nvps = new ArrayList<NameValuePair>();
	                nvps.add(new BasicNameValuePair("accountType", "HOSTED_OR_GOOGLE"));
	                nvps.add(new BasicNameValuePair("Email", "207project@gmail.com"));
	                nvps.add(new BasicNameValuePair("Passwd", "207group04"));
	                nvps.add(new BasicNameValuePair("service", "writely"));// Name of Google service 
	     
	                UrlEncodedFormEntity ent;
	                try {
	                        ent = new UrlEncodedFormEntity(nvps,HTTP.UTF_8);
	                        System.out.println("ent: "+ent);
	                        post.setEntity(ent);
	                        HttpResponse responsePOST = client.execute(post);
	                        System.out.println("responsePOST: "+responsePOST);
	                        HttpEntity resEntity = responsePOST.getEntity();
	                        System.out.println("resentity: "+resEntity);
	                        if (resEntity != null) {
	                        	
	                                String authToken=  EntityUtils.toString(resEntity);
	                                System.out.println("RESPONSE is "+ authToken );
	                             
	        	                       }
	           } catch (UnsupportedEncodingException e) {
	                        e.printStackTrace();
	                } catch (ClientProtocolException e) {
	                        e.printStackTrace();
	                } catch (IOException e) {
	                        e.printStackTrace();
	                }
	                
	        	
	        	
	        }

	}

